<%@page import="study.top.mydb.items.WishListShowItem"%>
<%@page import="java.util.ArrayList"%>
<%@page import="study.top.mydb.WishListProduct"%>
<%@page import="study.top.mydb.items.WishListItem"%>
<%@page import="study.top.mydb.items.MemberItem"%>
<%@page import="study.top.mydb.WishList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page session="true" %>
<%@ include file="/../dbcon.jsp" %>
<%
	int n_budget = web.getInt("budget");
	int n_sum = 0;
	int n_change = 0;

	int mem_seq = 0;	

	// 세션에 저장된 로그인한 회원의 정보
	MemberItem memberItem = (MemberItem)session.getAttribute("MemberItem");

	if (memberItem != null) {
		mem_seq = memberItem.getSeq();
	}
	
	boolean result = false;
			
	if (n_budget > 0) {
		WishList wl = new WishList();
		result = wl.setBudget(mem_seq, n_budget);
		
		WishListItem w_item = wl.show(mem_seq);
		
		WishListProduct wlp = new WishListProduct();
		ArrayList<WishListShowItem> wishlist_list = wlp.wishListMember(mem_seq);
		
		// 로그인한 회원의 위시리스트 총 합계
		if (wishlist_list != null) {
			for (int i = 0; i < wishlist_list.size(); i++) {
				WishListShowItem item = wishlist_list.get(i);
				n_sum += item.getSum();
			}
		} 
			n_change = n_budget - n_sum;	
	}
	
	// true/예산/위시리스트합계/잔액
	out.print("" + result + "/" + n_budget + "/" + n_sum + "/" + n_change);
%>